/*
 *  Copright: 2008 Philipp Leitner, Distributed Systems Group,
 *            TU Wien, leitner@infosys.tuwien.ac.at
 *
 *  This file is part of DAIOS.
 *
 *  DAIOS is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as
 *  published by the Free Software Foundation.
 * 
 *  DAIOS is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with DAIOS.  If not, see
 *  <http://www.gnu.org/licenses/>.
 * 
 */

package at.ac.tuwien.infosys.dsg.daiosPlugins.axis2;

import java.io.IOException;
import java.net.URL;

import javax.wsdl.WSDLException;

import at.ac.tuwien.infosys.dsg.daios.framework.DaiosInterceptor;
import at.ac.tuwien.infosys.dsg.daios.exceptions.AmbigiousException;
import at.ac.tuwien.infosys.dsg.daios.framework.interfaces.IConstants;
import at.ac.tuwien.infosys.dsg.daios.framework.interfaces.IServiceFrontendImplementor;

/**
 * This is the registry for concrete invoker implementations. It should
 * only be by the Daios Axis2 plugin internally.
 * 
 * @author philipp
 *
 */
public class Axis2InvokerTable {
	
	/**
	 * Get a new service frontend implementor.
	 * 
	 * @param type The invocation style (SOAP or REST).
	 * @param location The endpoint of the invocation.
	 * @return A new service frontend implementor fitting
	 * the style given.
	 * 
	 * @throws WSDLException
	 * @throws AmbigiousException
	 * @throws IOException
	 */
	public static IServiceFrontendImplementor getInstance(
		String type, URL location, DaiosInterceptor interceptor)
		throws WSDLException, AmbigiousException, IOException {
		
		if(type.equals(IConstants.SOAP_STYLE))
			return new Axis2ServiceInvoker(location, interceptor);
		else
			if(type.equals(IConstants.REST_STYLE))
				return new Axis2RESTInvoker(location, interceptor);
	
				
		throw new IllegalArgumentException("Invocation style "
				+type+" is unsupported.");
		
	}
	
}
